# 双指针 一个先走 一个后走
class Solution:
    # k为任意数
    def FindKthToTail(self, head, k):
        if not head or k<=0:
            return None
        p1 = head
        p2 = head
        # 因为长度为k的链表只能走k-1次
        while k > 1:
            if p2.next != None:
                p2 = p2.next
                k-=1
            else:
                return None
        while p2.next != None:
            p1 = p1.next
            p2 = p2.next
        return p1
# 用while
class Solution:
    def FindKthToTail(self, head, k):
        # write code here
        if not head or k<=0:
            return None
        slow = head
        quick = head
        # 正常是n-1次走完, 走n次是为了多走一个方便删除

        while k>1:
            quick=quick.next
            k -= 1
        if not quick:
            return
        while quick.next:
            quick=quick.next
            slow=slow.next
        return slow